package com.controller;

import com.entity.Employee;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
@Controller
@RequestMapping("/employeesController")
public class EmployeeController {
    @RequestMapping("/employees")
    @ResponseBody
//    public List<Employee> getAll(){
//        System.out.println("getAll");
//        List<Employee> employees = Arrays.asList(new Employee[]{new Employee(1,"小王"),new Employee(2,"小张")
//        ,new Employee(3,"小李")});
//        return employees;
//    }

    public ModelAndView getAll(){
        System.out.println("getAll");
        List<Employee> employees = Arrays.asList(new Employee[]{new Employee(1,"小王"),new Employee(2,"小张")
                ,new Employee(3,"小李")});
        ModelAndView mv = new ModelAndView();
        mv.addObject("employees",employees);
        mv.setViewName("/back/employee/list");
        return mv;

    }
}
